 {% extends "layout.html" %}




   {% block head %}
   {% endblock %}

   {% block right%}

<style>
    .layui-form-label{
        float:left;display:block;padding:9px 15px;width:80px;font-weight:400;line-height:20px;text-align:left;
    }
    .grid-demo input{
        width: 300px;
    }
    .layui-form-select dl {
        height: 150px;
        position: absolute;
        left: 0;
        top: 42px;
        padding: 5px 0;
        z-index: 899;
        min-width: 300px;
        border: 1px solid #d2d2d2;
        max-height: 300px;
        overflow-y: auto;
        background-color: #fff;
        border-radius: 2px;
        box-shadow: 0 2px 4px rgb(0 0 0 / 12%);
        box-sizing: border-box;
    }
    .layui-form-select .layui-edge {
        position: absolute;
        right: -90px;
        top: 50%;
        cursor: pointer;
        border-width: 6px;
        border-top-color: #c2c2c2;
        border-top-style: solid;
        -webkit-transition: all .3s;
    }
</style>

<div class="layui-col-sm5"  style="margin: 0px 10px auto 120px; padding: 30px;" >
<div class="grid-demo">
   <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>个人信息</legend>
</fieldset>

 <div class="layui-form" >

  <div class="layui-form-item">
    <label class="layui-form-label" >ID</label>
    <div class="layui-input-inline">
      <input id="user_id_01" type="text"  readonly name="title"   lay-verify="required" value={{user[0]}} autocomplete="off" class="layui-input">
    </div>
  </div>

   <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
      <input id="user_name" type="text" name="title" required  lay-verify="required" value={{user[1]}} autocomplete="off" class="layui-input">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">邮箱</label>
    <div class="layui-input-inline">
      <input  id="e_mail" type="text" name="title" required  lay-verify="required" value={{user[2]}} autocomplete="off" class="layui-input">
    </div>
  </div>

   <div class="layui-form-item">
    <label class="layui-form-label">学历</label>
    <div class="layui-input-inline">


        	<select  lay-filter="business2"  lay-search  title= {{user[3]}}
                     class="select"  lay-verify="type" name="business2"   >
            <option  value={{user[3]}} selected  >{{user[3]}}</option>
            {% for i  in  education %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>


    </div>
  </div>


 <div class="layui-form-item">
    <label class="layui-form-label">工作经验</label>
    <div class="layui-input-inline">
      <input  id="work_experience" type="text" name="title" required  lay-verify="required"
             autocomplete="off" class="layui-input" value={{user[4]}} >
    </div>
  </div>


 <div class="layui-form-item">
    <label class="layui-form-label">当前工作</label>
    <div class="layui-input-inline">
        	<select  lay-filter="business3"  lay-search  title= {{user[5]}}
                     class="select"  lay-verify="type" name="business3"   >
            <option  value={{user[5]}} selected  >{{user[5]}}</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>

    </div>
  </div>




<div class="layui-form-item">
    <label class="layui-form-label">预测工作01</label>
    <div class="layui-input-inline">

        <select  lay-filter="business4"  lay-search  title= {{user[7]}}
                     class="select"  lay-verify="type" name="business4"   >
            <option  value={{user[7]}} selected  >{{user[7]}}</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>


    </div>
  </div>

<div class="layui-form-item">
    <label class="layui-form-label">预测工作02</label>
    <div class="layui-input-inline">

             <select  lay-filter="business5"  lay-search  title= {{user[8]}}
                     class="select"  lay-verify="type" name="business5"   >
            <option  value={{user[8]}} selected  >{{user[8]}}</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>



    </div>
  </div>

<div class="layui-form-item">
    <label class="layui-form-label">预测工作03</label>
    <div class="layui-input-inline">

                <select  lay-filter="business6"  lay-search  title= {{user[9]}}
                     class="select"  lay-verify="type" name="business6"   >
            <option  value={{user[9]}} selected  >{{user[9]}}</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>
        <br>
    </div>
  </div>


     <div class="layui-form-item">
    <label class="layui-form-label">当前薪资</label>
    <div class="layui-input-inline">

      <input id="current_pay" type="text" name="title" required  lay-verify="required"
             autocomplete="off" class="layui-input" value={{user[6]}} >
    </div>
  </div>


    </div>
  </div>
     <div class="layui-form-item" style="right: 300px;width: 100%;">
    <div class="layui-input-block">
      <button id="user_alter" class="layui-btn" lay-submit lay-filter="formDemo">确认修改</button>
   </div>


     <blockquote class="layui-elem-quote">
         说明：修改个人信息后可以在个人报告及时更新
     </blockquote>

 </div>
 </div>
<script></script>
<script>
//Demo

function ShowDiv() {


	      $('#user_alter').html("<img src=\"/static/images/hc.gif\" alt=\"\"/>操作中，请稍候...");
	  	   $('#user_alter').css({"background-color":"grey"});



}

//隐藏加载数据
function HiddenDiv() {
	 $('#user_alter').html("确认修改");
	 $('#user_alter').css({"background-color":"#009688"});
}

	$("#user_alter").click(




		function () {

		     ShowDiv();

            var  user_id = $('#user_id_01').val();
            var  user_name = $('#user_name').val();
            var  e_mail = $('#e_mail').val();
            var  work_experience = $('#work_experience').val();
            var  current_pay =  $('#current_pay').val();
		    if(current_pay !="" && ! current_pay.match("(.*?) (.*?)")  &&
            user_name !="" && ! user_name.match("(.*?) (.*?)")  &&
            e_mail !="" && ! e_mail.match("(.*?) (.*?)")  &&
            work_experience !="" && ! work_experience.match("(.*?) (.*?)")) {
                $.ajax({
                    //请求方式
                    type: "POST",
                    //请求的媒体类型
                    contentType: "application/json;charset=UTF-8",
                    //请求地址
                    url: "/personal_alter",
                    //数据，json字符串
                    data: JSON.stringify({
                        'user_id': user_id,
                        'user_name': $('#user_name').val(),
                        'e_mail': $('#e_mail').val(),
                        'work_experience': $('#work_experience').val(),
                        'current_pay': $('#current_pay').val(),
                    }),
                    //请求成功
                    success: function (result) {
                        		        HiddenDiv();

                        if (result == "success") {
                            layer.open({
                                title: '提示',
                                content: '修改成功'
                            });
                        }
                    },
                    //请求失败，包含具体的错误信息
                    error: function (e) {
                        console.log(e.status);
                        console.log(e.responseText);
                    }
                });
            }else{
		        HiddenDiv();
		        layer.open({
                title: '提示',
                content: '修改内容含空格！'
            });
            }

		}
	)

//  修改个人资料-学历
 layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;
        // 监听全选
                /*用户-修改权限*/
          form.on('select(business2)', function(obj){
          var user_id =  $('#user_id_01').val();
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/personal_alter_education",
                   //数据，json字符串
                   data: JSON.stringify({
                       'content': content,
                       'user_id': user_id
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
        });
});


         form.on('select(business3)', function(obj){
          var user_id =  $('#user_id_01').val();
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/personal_alter_current_work",
                   //数据，json字符串
                   data: JSON.stringify({
                       'content': content,
                       'user_id': user_id
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
        });
});

          form.on('select(business4)', function(obj){
          var user_id =  $('#user_id_01').val();
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/personal_alter_foretell_work01",
                   //数据，json字符串
                   data: JSON.stringify({
                       'content': content,
                       'user_id': user_id
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
        });
});

        form.on('select(business5)', function(obj){
          var user_id =  $('#user_id_01').val();
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/personal_alter_foretell_work02",
                   //数据，json字符串
                   data: JSON.stringify({
                       'content': content,
                       'user_id': user_id
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
        });
});

        form.on('select(business6)', function(obj){
          var user_id =  $('#user_id_01').val();
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/personal_alter_foretell_work03",
                   //数据，json字符串
                   data: JSON.stringify({
                       'content': content,
                       'user_id': user_id
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
        });
});


        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });





	$("#user_id_01").click(
		function(){
            layer.open({
           title: '警告',
           content: '不能修改ID'
       });
		}
	);

</script>



   {% endblock %}

    {% block footer%}
    {% endblock %}